var self = this;
var mySwiper;
var floorDataRe;
var resetTime = ''; //屏保定时器
var searchList = ''; //搜索的数据库
var realDistance = ""; //路线总长
var endPointData = '' //装终点点位的数据
var realTimeCountdown = ''; //耗时倒计时的计时器
var allPointsData = {}; //所有POINTID的信息
var mytime = '';
var allFloorData = '';
var searchResultsOnMapBoxH //searchResultsOnMapBox的高
var isStart = false;
var isEnd = false; //已有路线，点击搜索栏是设置起点还是终点的判断
var fastSearchData = '' //快捷功能区数据
var departmentsInfo = '' //科室页的科室数据
var registeredDepartment = '' //挂号科室
var noMarkIsSetEnd = false; //是否卫生间   出入口类型
var facilityModify = false //是否卫生间  电梯等类型
var unableClick = {} //出入口  洗手间  等无法直接出发地图点击事件  传递他的pointid
var isLoadingEnd = false //加载loading完成判断
var noNametype = ['wheelchair wc', 'toilets', 'lifts', 'escalator', 'stair', 'nursery room']
var keyArr = [] //搜索缓存数组
var rankPublic = '' //导航评分全局
var commentPublic = '' //导航评语全局
var popularSearchData = '' //热门搜索数据
var nowDate = '' //当前日期
var nowTime = '' //当前时刻
var nowWeather = '' //当前温度
var qrCodeData = {} //二维码需要附带的数据
var multipleSelectionEndPoint = '' //多结果是的终点值传输
var object = {
	no: "5", //一系列操作之后  展开楼层模块该显示楼层
	menuNo: '0',
	startP: '',
	endP: '',
	startFid: '',
	endFid: '',
	isFind: false, //是否在寻路状态下
	xlId: {},
	allFoors: {},
	zoomLevel: 20,
	isTrue: true, //静音   ios不兼容
	floorid: GetQueryString('floorid') ? GetQueryString('floorid') : initFloolrPublic,
	mark: GetQueryString('mark'),
	departName: GetQueryString('departName'),
	floorName: GetQueryString('floorName'),
	mac: GetQueryString('mac'),
	ip: GetQueryString('ip'),
	floorData: '',
	orderFloors: {},
	order: 5, //初始楼层order
	ispoint: true,
	isInitOrder: true,
	location: false,
	timer: '', //寻路定时器
	pathfinding: JSON.parse(GetQueryString('pathfinding')), //ids扫描跳转参数
	department: GetQueryString('department'),
	shopList: '',
	moFloorid: {
		start: '',
		end: '',
		startArea: '',
		endArea: ''
	},
	areaID: "",
	shopID: {
		id: 'L95',
		floorid: 'LG'
	},
	getServeData: function (data, fn) {
		$.ajax({
			type: "GET",
			url: 'https://map.ckiosk.cn/webAPI/ClientService.asmx/Command?callback',
			data: data,
			dataType: "JSONP",
			success: function (s) {
				fn(s);
			}
		});
	}
}
var yGetData = {
	getData: function (pid, lan, command, parameter) {
		var datas = {
			"code": "{pid:'" + pid + "',lan:'" + lan + "',command:'" + command + "',parameter:" + JSON.stringify(parameter) + "}"
		}
		object.getServeData(datas, function (data) {
			if (data.c == 200) {
				fastSearchData = data.v.FunctionInfo
				departmentsInfo = data.v.DepartmentsInfo.reverse()
				// console.log(departmentsInfo)
				createFloorList()

			}
		})
	},
	getRegisteredData: function (pid, lan, command, parameter) {
		var datas = {
			"code": "{pid:'" + pid + "',lan:'" + lan + "',command:'" + command + "',parameter:" + JSON.stringify(parameter) + "}"
		}
		object.getServeData(datas, function (data) {
			if (data.c == 200) {
				console.log(data.v)
				registeredDepartment = data.v
			}
		})
	},
	updateHotPoint: function (pid, lan, command, parameter) {
		var datas = {
			"code": "{pid:'" + pid + "',lan:'" + lan + "',command:'" + command + "',parameter:" + JSON.stringify(parameter) + "}"
		}
		object.getServeData(datas, function (data) {})
	},
	getPopularSearch: function (pid, lan, command, parameter) {
		var datas = {
			"code": "{pid:'" + pid + "',lan:'" + lan + "',command:'" + command + "',parameter:" + JSON.stringify(parameter) + "}"
		}
		object.getServeData(datas, function (data) {
			popularSearchData = data.v
			console.log(data.v)
		})
	},
}
var arr = [{
		'image': './images/Department_icon_guahao.png',
		'searchName': '挂号处',
		'title': '去挂号'
	}, {
		'image': './images/Department_icon_jiaofei.png',
		'searchName': '收费处',
		'title': '去缴费'
	}, {
		'image': './images/Department_icon_quyao.png',
		'searchName': '去取药',
		'title': '去取药'
	}, {
		'image': './images/Department_icon_diandi.png',
		'searchName': '去输液',
		'title': '去输液'
	}, {
		'image': './images/Department_icon_chouxue.png',
		'searchName': '去抽血',
		'title': '去抽血'
	}, {
		'image': './images/Department_icon_baogao.png',
		'searchName': '取报告',
		'title': '取报告'
	}, {
		'image': './images/Department_icon_wc.png',
		'searchName': '洗手间',
		'title': '洗手间'
	}, {
		'image': './images/Department_icon_crk.png',
		'searchName': '出入口',
		'title': '出入口'
	},
	// {
	// 	'image': './images/Department_icon_bld.png',
	// 	'searchName': '便利店',
	// 	'title': '便利店'
	// }, {
	// 	'image': './images/Department_icon_atm.png',
	// 	'searchName': 'ATM',
	// 	'title': 'ATM'
	// }
]


$(document).ready(function () {
	document.onmousemove = resetTask;
	document.onclick = resetTask;
	if (object.pathfinding) {
		object.floorid = object.pathfinding.startFloorid
	}
	init()
	// setInterval(function () {
	// 	fnDate();
	// }, 1000);
	searchList = GIM.DisplayModel.prototype.allArea;

	$('.compass').on('click', function () {
		self.map.setPolarAngle(0);
		self.map.setAzimuthalAngle(0);
		$(this).css({
			'transform': 'rotate(90deg)'
		})
	});
	setTimeout(() => {
		yGetData.getData(projectIdPublic, 'SC', 'gethospitalfunctioninfo', "{'KEY':'BAF3CB32-E8F2-40A6-AE1A-A5BFE2CB6E14'}")
		fnDateRefresh()
		getWeatherDataRefresh()
	}, 0);
});


function stopWindowText() {
	window.event.returnValue = false;
	return false;
}

// window.alert = function (name) {
// 	var iframe = document.createElement("IFRAME");
// 	iframe.style.display = "none";
// 	iframe.setAttribute("src", 'data:text/plain,');
// 	document.documentElement.appendChild(iframe);
// 	// window.frames[0].window.alert(name);
// 	iframe.parentNode.removeChild(iframe);
// };


//地图初始化参数配置
function init() {
	// 文本显示层级   数值越大  越容易显示
	GIM.SHOW_SPRITE_LENGTH = 6000 * 6;
	/* 公共设施显示层级 */
	GIM.SHOW_Facility_LENGTH = 1300 * 2;
	GIM.DEBUG_MODE = false; //是否开启调试，true为开启，false为u开启，默认不开启
	var container = document.getElementById('mapContainer')
	container.style.cssText = "width:" + (container.clientWidth / 1) + "px;height:" + (container.clientHeight / 1) + "px;overflow: hidden;position: absolute;text-align:right";
	var params = {
		debug: GIMDegug,
		initCompleted: initCompelte,
		onSelected: onSelected,
		container: container,
		themeID: "1003",
		accessToken: "BAF3CB32-E8F2-40A6-AE1A-A5BFE2CB6E14",
		// backgroundColor: '#f2f2f2',
		projectID: projectIdPublic,
		initFloorID: object.floorid,
		// cloudID: 'D2D2A1CC-BE08-4FA8-9559-DFE8C0C1F0A2',
		showLabelType: "No.",
		crossBuild: true,
		groundLayer: true,
		bgisSvg: true,
		preCreation: false,
	}
	pvuv(params.projectID);
	// 地图离屏幕的距离
	// GIM.far = 5000;
	// 地图放大级别，数字越小放大级别越大
	GIM.near = 750;
	self.map = new GIM.Map3D(params);

	// 您的位置显示
	GIM.NODE_TYPE_MACHINE = "1"
	self.map.maxFlatHeight = 15;
	self.map.facilityScale = 1.2
	self.map.maxCameraRadius = 5000;
	self.map.pathElevation = 40;
	self.map.simulateMoveSpeed = 3;
	self.map.setBackgroundColor(0xeffdf6);
	self.map.pathThickness = 30;
	self.map.showCompass(false);
	self.map.regCompassChange(function (angel) {
		$('.compass').css({
			'transform': 'rotate(' + angel + 'deg)'
		})
	})
}


//地图初始化后进行操作
function initCompelte($floorData) {
	yGetData.getPopularSearch(projectIdPublic, 'SC', 'GetHotSearch', "{}")
	floorDataRe = $floorData.reverse()
	allFloorData = $floorData
	// console.log(floorDataRe)



	allPointsData = GIM.Points;

	// console.log('allPointsData :', allPointsData);
	// if (self.map.pathDownloaded == true) {
	// 	console.log("path download complete")
	// } else {
	// 	self.map.regPathDownloaded(function () {
	// 		console.log("path download complete")
	// 	})
	// }
	// var a = GIM.Points
	object.startP = self.map.startPID = instrumentPosition
	object.floorData = floorDataRe;
	object.floorData = object.floorData.sort(function (a, b) {
		return a.order - b.order
	});
	object.floorData.forEach(function (t) {
		object.allFoors[t.FloorID] = t.Name
		object.orderFloors[t.Order] = t.FloorID
	})

	$(".exitConfirmation").css("opacity", "0")
	$(".exitConfirmation").css("top", "-.9rem")
	bindFloor(object.floorData)
	if (object.mark) { //分享
		setTimeout(() => {
			$(".message").hide()
		}, 0);
		if ($('.floorListInfo').css('display') == 'block') {
			$('.homePage').hide()
			$('.message').show()
			setTimeout(function () {
				self.map.addMarkToPoint(object.mark, "mark", true)
				// $(".clickDetails").fadeIn()
				$('.shareDataInput').val(object.departName)
				$('.pointName').html(object.departName)
				$('.pointFloor').html(object.floorName)
			}, 500)
		}
	} else if (object.pathfinding) { //扫码
		self.map.startNode.pointID = object.pathfinding.startId;
		setTimeout(function () {
			$('#loadings').css({
					'display': 'block'
				}).children('.load_xun').css({
					display: 'block'
				})
				.siblings().css({
					display: 'none'
				})
			self.map.showFloors([object.pathfinding.endFloorid])
			self.map.setEndArea(object.pathfinding.endId, false);
			self.map.searchPath(function (msg) {
				if (msg == 'done') {
					// selectionBoxBottm()
					self.map.zoomLevel(object.zoomLevel);
					$('#loadings').css('display', 'none')
				} else {
					$('#loadings').css('display', 'none')
					alert('寻路失败');
					return;
				}
			}, callback)
		}, 5000)
	}
	if (object.department) { //挂号
		setTimeout(() => {
			yGetData.getRegisteredData(projectIdPublic, 'SC', 'gethospitaldepartmentstidsinfo', "{'KEY':'BAF3CB32-E8F2-40A6-AE1A-A5BFE2CB6E14'}")
		}, 0);
		if (self.map.pathDownloaded == true) {
			if (registeredDepartment.length > 0) {
				registrationMatching()
			} else {
				var timer = setInterval(function () {
					if (registeredDepartment.length > 0) {
						registrationMatching()
						clearInterval(timer)
					}
				}, 500)
			}
		} else {
			self.map.regPathDownloaded(function () {
				if (registeredDepartment.length > 0) {
					registrationMatching()
				} else {
					var timer = setInterval(function () {
						if (registeredDepartment.length > 0) {
							registrationMatching()
							clearInterval(timer)
						}
					}, 500)
				}
			})
		}
	} else {
		// $(".floorToggle").html("1F")
		$('#loadings').css('display', 'none');
		$('.waiting').html('地图加载完成').delay(2500).fadeOut()
	}
	mapResetPublic()
	createWXConfig(postData);
	// FloorDetection()



	//暂停模拟导航的时候触发
	self.map.regNavigationPause(function () {
		$('.mogo').css("background-image", "url('../images/mogo.png')");
		$('.mogo').text('继续进行模拟导航');
		isPause = true;
	})

}
// 挂号匹配函数
function registrationMatching() {
	for (var j = 0; j < registeredDepartment.length; j++) {
		if (registeredDepartment[j].ThirdPartyIDS.split("|").indexOf(object.department) != -1) {
			$(".homepage,.searchBox").hide()
			console.log(registeredDepartment[j].ThirdPartyIDS.split("|"))
			for (var i = 0; i < allFloorData.length; i++) {
				var allFloorDataA = allFloorData[i].Area
				for (var o = 0; o < allFloorDataA.length; o++) {
					if (registeredDepartment[j].PI == allFloorDataA[o].PI) {
						// console.log(allFloorDataA[o])
						$(".opEndP").val(allFloorDataA[o].Tag + ' ' + object.allFoors[registeredDepartment[j].FI] + ' ' + allFloorDataA[o].AN)
					}
				}
			}
			// $(".floorToggle").html(object.allFoors[registeredDepartment[j].FI])
			$(".setPointTip,.operation").slideDown()
			// setPointBottom()
			$('.compass').css({
				'top': '2.81rem'
			})
			$(".looking").show().html('正在查看 ' + object.allFoors[registeredDepartment[j].FI] + '')
			self.map.addMarkToPoint(registeredDepartment[j].PI, "end", true)
			object.endP = self.map.endPID = registeredDepartment[j].PI;
		} else {
			// $(".floorToggle").html("1F")
			// $(".looking").html('正在查看 ' + "1F" + '')
			// $('.waiting').show().html('未找到该科室，请确认后重试').delay(3500).fadeOut()
		}
	}
}
// 创建科室页科室列表
function createFloorList() {
	var li = ''
	var lis = ''
	var ul = ''
	// console.log(departmentsInfo)
	for (let i = 0; i < departmentsInfo.length; i++) {
		// console.log(departmentsInfo[i])
		var departmentsInfoData = departmentsInfo[i].data
		departmentsInfoData = departmentsInfoData.sort(compare('Order'))
		lis = '';
		for (let j = 0; j < departmentsInfoData.length; j++) {
			// console.log(departmentsInfoData[j])
			var departmentsInfoDataO = departmentsInfoData[j].data
			li = '';
			departmentsInfoDataO = departmentsInfoDataO.sort(compare('O'))
			for (let o = 0; o < departmentsInfoDataO.length; o++) {
				// console.log(departmentsInfoDataO)
				li = li + '<li onclick="toThisPoint(' + departmentsInfoDataO[o].PI + ',' + "\'" + departmentsInfoData[j].FI + "\'" + ',' + "\'" + departmentsInfoDataO[o].N + "\'" + ',' + 9 + ',' + "\'" + departmentsInfo[i].Name + "\'" + ')">' + '<span > ' + departmentsInfoDataO[o].N + ' </span>' + '</li > '
			}
			lis = lis + '<div class="buildingFloors">' + '<div class="buildingFloorsLeft">' + '<span>' + departmentsInfoData[j].Name + '</span>' + '</div>' + '<div class="buildingFloorsRight">' + li + '</div>' + '</div>'
		}
		ul = ul + '<div class="buildingBar swiper-wrapper">' + '<div class="buildingTitle swiper-slide" id="buildingTitle">' + '<span>' + departmentsInfo[i].Name + '</span>' + '<span>' + '</span>' + '</div>' + '<div class="buildingContent swiper-slide">' + lis + '</div>' + '</div>'
	}
	$(".floorListInfo").append(ul)
	listScroolPc();


}

//创建楼层
function bindFloor($floorData) {
	var ul = $(".swiper-wrapper1"),
		liHtml = '';
	ul.find("li").remove();
	floorDataRe = $floorData.reverse()
	for (var i = floorDataRe.length - 1, len = floorDataRe.length; i >= 0; i--) {
		liHtml = liHtml + `<li name=${floorDataRe[i].FloorID} class="swiper-slide swiper-slide1"><button type="button" class="btn btn-default" data=${floorDataRe[i].FloorID} value =${floorDataRe[i].Name} >${floorDataRe[i].Name}</button></li>`;
		if (GetQueryString('floorid') && GetQueryString('floorid') == floorDataRe[i].floorID && object.isInitOrder) {
			object.order = floorDataRe.length - floorDataRea[i].order;
		}
		if (GetQueryString('pathfinding') && JSON.parse(GetQueryString('pathfinding')).startFloorid == floorDataRe[i].floorID && object.isInitOrder) {
			object.order = floorDataRe.length - floorDataRe[i].order;
		}
	};
	object.floorid = floorDataRe[floorDataRe.length - object.order - 1].floorID
	ul.append(liHtml);
	mySwiper = myswiper(floorDataRe)
	mySwiper.init()
	var num = Math.ceil(arr.length / 8)
	var html = '';
	var htmls = '';
	var wrapper = $('.swiper-wrapper2')
	for (i = 0; i < num; i++) {
		html = html + '<div class="swiper-slide swiper-slide2 shortcut clearfix">' +
			'<ul class="pictures clearfix">' +
			'</ul>' +
			'</div>'
	}
	wrapper.append(html)
	var slide = $('.swiper-slide2');
	for (i = 0; i < slide.length; i++) {
		for (j = i * 8; j < arr.length; j++) {
			// console.log(arr[j])
			if (j == (i + 1) * 8) {
				break;
			}
			htmls = htmls + '<li onclick=searchTopic("' + (arr[j].searchName ? arr[j].searchName : '') + '")>' +
				'<img class="picture' + j + ' picture" src="' + arr[j].image + '">' +
				'</img>' +
				'<span>' + arr[j].title + '</span>' +
				'</li>'
		}
		$(slide[i]).find('ul').append(htmls)

		htmls = ''
	}
	if (departmentsInfo.length > 0) {
		$(".listLoading,.slideListLoading").hide()
		// setTimeout(() => {
		// 	$('.floorListHintBox').fadeIn()
		// }, 800);

		$(".floorListInfo,.slideList").show()
		setTimeout(() => {
			$('.buildingBar').fadeIn()
			$('.buildingBar').css('margin-top', '0')
			for (var i = 0; i < 4; i++) {
				if (i > 0) {
					// console.log(i)
					$('.buildingBar').eq(i).find('div').eq(0).click()
				}
			}
		}, 100);
		$(".homePage .areaList .searchBar .enterMap").children().remove()
		$(".homePage .areaList .searchBar .enterMap").removeAttr("disabled")
		$(".homePage .areaList .searchBar .enterMap").html("地图")
	}
	var mySwipers = new Swiper('.swiper-container2', {
		pagination: '.swiper-pagination',
		freeMode: false,
		observer: true, //修改swiper自己或子元素时，自动初始化swiper   
		observeParents: true,
		//pagination : '#swiper-pagination1',
		pagination: {
			el: '.swiper-pagination',
		},
	})

};
var afterFastSearchData = []
// 科室页快捷选单点击方法
function searchTopic(key) {
	afterFastSearchData = []
	noMarkIsSetEnd = false;
	facilityModify = false;
	for (let i = 0; i < fastSearchData.length; i++) {
		var arrD = fastSearchData[i].data
		for (let j = 0; j < arrD.length; j++) {
			if (key == fastSearchData[i].Name) {
				var arrS = {}
				arrS.PI = arrD[j].PI
				arrS.FloorID = arrD[j].FI
				arrS.BN = arrD[j].N
				arrS.T = arrD[j].T
				afterFastSearchData.push(arrS)
			} else if (key == '洗手间' || key == '出入口') {
				noMarkIsSetEnd = true
			} else if (key == '洗手间') {
				facilityModify = true
			}
		}
	}
	enterMap()
	toSearchResultsOnMap()
	$('.changeFBox').hide()
}

//点击地图设置起始点和终点
function onSelected(data) {
	isLoadingEnd = true
	console.log(data)
	// 给终点数据赋值
	if (data.tag) {
		endPointData = data.tag + ' ' + object.allFoors[data.floorID] + ' ' + data.name
	} else {
		endPointData = object.allFoors[data.floorID] + ' ' + data.name
	}
	self.map.zoomLevel(8);




	if (object.startP) {
		object.endP = self.map.endPID = data.nodeId
		$('.clickDetails .opStartP').val('我的位置')
		$('.clickDetails .opEndP').val(endPointData)

		pathGo('liftsFirst')
		setTimeout(() => {
			object.endP = self.map.endPID = data.nodeId

		}, 10);

	}
	$('.inputName,.shares').css('display', 'none');
	// $('.looking').hide().show().html('正在查看 ' + object.allFoors[data.floorID] + '');
	$('.gSearch').css('display', 'block');
	$('.mo_daohang,.mo_tishi').slideUp('slow');
	if (noNametype.indexOf(data.code) != -1) {
		$('.pointName').html(judgmentOfTheTypeOfPublicFacilities(data.code));
	} else {
		$('.pointName').html(data.shopName ? data.shopName : data.name);
	}
	$('.searchBox input').val($('.pointName').html())
	if (data.tag) {
		$('.pointFloor').html(data.tag + ' ' + object.allFoors[data.floorID]);
	} else {
		$('.pointFloor').html(object.allFoors[data.floorID]);
	}
	object.mark = data.nodeId
	object.floorid = data.floorID
	object.departName = $('.pointName').html()
	object.floorName = $('.pointFloor').html()
	// if ($('.operation').css("display") == 'block') {
	// 	$('.setPointTip').slideUp()
	// 	$(".clickDetails").fadeIn()
	// $(".clickDetails .right").empty()
	// if ($(".opEndP").val() == '') {
	// 	$(".clickDetails .right").append("<div class = 'querenxuandian' onclick='setStartOrEnd()'>选择终点</div>")
	// } else if ($(".opStartP").val() == '') {
	// 	$(".clickDetails .right").append("<div class = 'querenxuandian' onclick='setStart()'>设为起点</div>")
	// }
	// 	setPointBottom()
	// } else if ($('.setPointTip').css("display") == 'block' && $('#endPoint').val() != '') {
	// 	$('.setPointTip').slideUp()
	// 	$(".clickDetails").fadeIn()
	// $(".clickDetails .right").empty()
	// if ($(".opEndP").val() == '') {
	// 	$(".clickDetails .right").append("<div class = 'querenxuandian' onclick='setStartOrEnd()'>选择终点</div>")
	// } else if ((".opStartP").val() == '') {
	// 	$(".clickDetails .right").append("<div class = 'querenxuandian' onclick='setStart()'>设为起点</div>")
	// }
	// 	setPointBottom()
	// } else if ($('.setPointTip').css("display") == 'block' && $('.clickDetails').css("display") == 'block') {
	// 	$('.setPointTip').slideUp()
	// 	$(".clickDetails").fadeIn()
	// $(".clickDetails .right").empty()
	// if ($(".opEndP").val() == '') {
	// 	$(".clickDetails .right").append("<div class = 'querenxuandian' onclick='setStartOrEnd()'>选择终点</div>")
	// } else if ($(".opStartP").val() == '') {
	// 	$(".clickDetails .right").append("<div class = 'querenxuandian' onclick='setStart()'>设为起点</div>")
	// }
	// 	setPointBottom()
	// } else if ($(".searchResultsOnMapBox").css("display") == "block") {
	// 	$(".searchResultsOnMapBox").hide()
	// 	$('.clickDetails').slideDown()
	// } else {
	// setPointBottom()
	// $(".clickDetails .right").empty()
	// $(".clickDetails .right").append("<span class='setPointBtn'  onclick='setStartOrEnd()'></span>")
	// $(".clickDetails").fadeIn()
	// }
	// if ($(".selectionBox").css('display') == 'block') {
	// 	setPointBottom()
	// }
	setStart = function () {
		self.map.cleanSelectUnit3D()
		object.xlId.startId = data.nodeId;
		object.moFloorid.start = data.floorID
		object.moFloorid.startArea = data.shopName ? data.shopName : data.name;
		object.startFid = data.floorID
		object.startP = self.map.startPID = data.nodeId;
		// console.log(object.startP)
		if (noNametype.indexOf(data.code) != -1) {
			if (data.tag) {
				$('#startPoint').val(data.tag + ' ' + object.allFoors[data.floorID] + ' ' + judgmentOfTheTypeOfPublicFacilities(data.code));
			} else {
				$('#startPoint').val(object.allFoors[data.floorID] + ' ' + judgmentOfTheTypeOfPublicFacilities(data.code));
			}
		} else {
			if (data.tag) {
				$('#startPoint').val(data.tag + ' ' + object.allFoors[data.floorID] + ' ' + (data.shopName ? data.shopName : data.name));
			} else {
				$('#startPoint').val(object.allFoors[data.floorID] + ' ' + (data.shopName ? data.shopName : data.name));
			}
		}
		$(".clickDetails,.searchBox").slideUp()
		$(".operation").slideDown()
		// setPointTipBottom()
		$(".compass").css("top", "2.81rem")
		if (object.startP != '' && object.endP != '') {
			$(".selectionBox").slideDown()
			$('.selection').hide()
			$('.selectionLoading').show()
			// selectionBoxBottm()
			setTimeout(() => {
				$(".loadings").hide()
				setTimeout(() => {
					$('.selection').fadeIn()
					$('.selectionLoading').hide()
				}, 500);
				pathGo('liftsFirst')
			}, 500);
		}
	}
	setEnd = function () {
		self.map.cleanSelectUnit3D()
		object.xlId.endId = data.nodeId;
		object.moFloorid.end = data.floorID
		object.moFloorid.endArea = data.shopName ? data.shopName : data.name
		object.endFid = data.floorID
		object.endP = self.map.endPID = data.nodeId;
		if (noNametype.indexOf(data.code) != -1) {
			if (data.tag) {
				$('#endPoint').val(data.tag + ' ' + object.allFoors[data.floorID] + ' ' + judgmentOfTheTypeOfPublicFacilities(data.code));
			} else {
				$('#endPoint').val(object.allFoors[data.floorID] + ' ' + judgmentOfTheTypeOfPublicFacilities(data.code));
			}
		} else {
			if (data.tag) {
				$('#endPoint').val(data.tag + ' ' + object.allFoors[data.floorID] + ' ' + (data.shopName ? data.shopName : data.name));
			} else {
				$('#endPoint').val(object.allFoors[data.floorID] + ' ' + (data.shopName ? data.shopName : data.name));
			}
		}
		$(".clickDetails,.searchBox").slideUp()
		// $(".searchBox").hide()
		$(".setPointTip,.operation").slideDown()
		// setPointTipBottom()
		$(".compass").css("top", "2.81rem")
		setTimeout(() => {
			// $(".opStartP").focus()
		}, 0);
		if (object.startP != '' && object.endP != '') {
			$(".selectionBox").slideDown()
			$('.selection').hide()
			$('.selectionLoading').show()
			// selectionBoxBottm()
			setTimeout(() => {
				$(".loadings").hide()
				setTimeout(() => {
					$('.selection').fadeIn()
					$('.selectionLoading').hide()
				}, 500);
				pathGo('liftsFirst')
			}, 500);
		}
	}
	// FloorDetection();
};


// 关于点击 卫生间  电梯等的类型判断
function judgmentOfTheTypeOfPublicFacilities(type) {
	switch (type) {
		case 'wheelchair wc':
			x = "无障碍卫生间";
			break;
		case 'toilets':
			x = "卫生间";
			break;
		case 'lifts':
			x = "直梯";
			break;
		case 'escalator':
			x = "扶梯";
			break;
		case 'stair':
			x = "楼梯";
			break;
		case '	nursery room':
			x = "育婴室";
			break;
	}
	return x
}

//起始点和终点交换
function twoPointExchange() {
	var middleID = ''
	var middleVal = ''
	if ($('.clickDetails .opStartP').val() != '') {
		middleVal = $('.clickDetails .opStartP').val();
	}
	self.map.clearPath(true)

	object.xlId.startId = object.startP
	object.xlId.endId = object.endP

	$('.floorToggleMinUl').children().remove()



	var middleId = object.xlId.startId

	object.xlId.startId = object.xlId.endId

	object.xlId.endId = middleId



	$('.clickDetails .opStartP').val($('.clickDetails .opEndP').val());
	$('.clickDetails .opEndP').val(middleVal);

	object.startP = self.map.startPID = object.xlId.startId;
	object.endP = self.map.endPID = object.xlId.endId;


	reverseInside()
	pathGo('liftsFirst')
}

//返回 
function goBack() {
	$('#startPoint').val("")
	$('#endPoint').val("")

	goBackInside()
	object.mark = ''
	dataFloorId = ''
	unableClick = {}
	object.isTrue = true;
	object.isFind = false
	self.map.areaClickEmbed = true;
	$(".searchResultsOnMapBox,.shares").slideUp()
	$('.searchResultsOnMapBox_close').removeClass('searchResultsOnMapBox_closeRotate')
	$(".searchBox,.scale").show()
	$('#endPoint,#startPoint').val(' ');
	$(".opStartP,.opEndP").val('')
	$('.gSearch,.inputName, .operation, .setPoint1, .clickDetails, #loadings,.setPointTip,.selectionBox').hide();
	// normalBottom()
	$('.searchInput input').val("")
	self.map.clearPath(true);
	self.map.cleanSelectUnit3D()
	self.map.showFloors([findFlooridByPointid(object.end)])
	object.startP = self.map.startPID = instrumentPosition


	setTimeout(() => {
		$(".clickDetails .clickDetailsQR").children().eq(0).css({
			'background-image': 'url(./images/Department_loading_hui60.gif)',
			'background-size': '50%',
			'background-position': '50%'
		})
	}, 1000);

	setTimeout(() => {
		mySwiper.slideTo(5, 300)
	}, 500);
	// 已经没有路线了
	pathFlag = false;
	$('.mask').hide();
	mapPositonReset()
}




// 分享点击方法
function share(number) {
	if (number == 1) {
		$('.clickDetails').slideUp('slow');
		$('.shares').slideDown('slow')
	} else {
		$('.clickDetails').slideDown('slow');
		$('.shares').slideUp('slow')
	}
}

// 放大地图
function biger() {
	console.log(self.map.cameraRadius)
	if (self.map.cameraRadius - 1000 < self.map.minCameraRadius) {
		self.map.cameraRadius = 1000
	} else {
		self.map.cameraRadius = self.map.cameraRadius - 1000
	}
}

// 缩小地图
function smaller() {
	console.log(self.map.cameraRadius)
	if (self.map.cameraRadius < self.map.maxCameraRadius) {
		if ((self.map.cameraRadius + 1000) > self.map.maxCameraRadius) {
			self.map.cameraRadius = 8000
		} else {
			self.map.cameraRadius = self.map.cameraRadius + 1000
		}
	}
}


// 寻路报错弹框方法
function searchPathFailClose() {
	$(".searchPathFailBox").hide()
	goBack();
}
// 截取url参数
function GetQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return unescape(r[2]);
	return null;
}

function replaceArg(url, arg, arg_val) {
	var pattern = arg + '=([^&]*)';
	var replaceText = arg + '=' + arg_val;
	if (url.match(pattern)) {
		var tmp = '/(' + arg + '=)([^&]*)/gi';
		tmp = url.replace(eval(tmp), replaceText);
		return tmp;
	} else {
		if (url.match('[\?]')) {
			return url + '&' + replaceText;
		} else {
			return url + '?' + replaceText;
		}
	}
	return url + '\n' + arg + '\n' + arg_val;
}

function replaceUrl($url) {
	var url = $url
	if (url.indexOf('?') == -1) {
		if (object.floorid) {
			url = url + '?floorid=' + object.floorid;
		} else {
			return
		}
		if (object.mark) {
			url = url + '&mark=' + object.mark
		} else {
			return
		}
	} else {
		if (object.floorid) {
			url = replaceArg(url, 'floorid', object.floorid);
		} else {
			return
		}
		if (object.mark) {
			url = replaceArg(url, 'mark', object.mark);
		} else {
			return
		}
	}
	return url
}

// 楼层模块滑动切换方法
function myswiper($floorData) {
	return new Swiper('.swiper-container1', {
		on: {
			click: function () {
				// $('.loadings').show()
				object.floorid = object.orderFloors[$floorData.length - mySwiper.activeIndex]
				$('.looking').hide().show().html('正在查看 ' + object.allFoors[object.floorid] + '');
				// $('.floorToggle').html("" + object.allFoors[object.floorid] + "")
				self.map.showFloors([object.floorid])
				$(".searchResultsOnMapBox").slideUp()
				self.map.regShowLoading(function (ccc) {
					if (ccc == true) {
						$('.loadings').show()
					}
					if (ccc == false) {
						$('.loadings').hide()
						mapPositonReset()
					}
				})
				mapPositonReset()
				$(".searchInput input").val('')
				if ($('.operation').css("display") == 'block') {
					$('.floorToggleMinUl,.scale,.changeFBox').css('bottom', '2.5rem');
					// $(".floorToggle").css('bottom', '2.45rem')
					// if (object.startP != '' || object.endP != '') {
					// 	$(".clickDetails").show()
					// } else {
					// 	$(".clickDetails").hide()
					// }
					$('.inputName, .setPoint1,.shares').css('display', 'none');
				} else {
					// normalBottom()
					// if (object.startP != '' || object.endP != '') {
					// 	$(".clickDetails").show()
					// } else {
					// 	$(".clickDetails").hide()
					// }
					$('.inputName, .setPoint1,.shares,.operation,.setPointTip').css('display', 'none');
				}
				// $(".floorToggle").fadeIn()
			},
			touchStart: function () {
				Swiper.slideToclickedSlide = false;
			},
			init: function () {
				// console.log("myswiper was init")
			}
		},
		init: false,
		direction: 'vertical',
		slidesPerView: 'auto',
		initialSlide: object.no,
		slideToClickedSlide: true,
		centeredSlides: true,
		freeMode: true,
		preventClicks: false,
		preventLinksPropagation: false, //阻止滑动点击
		preventclicksPropagation: false,
		touchRatio: 1.5, //触摸变慢
		// shortSwipes: true,
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
		observeParents: true, //将observe应用于Swiper的父元素。当Swiper的父元素变化时，例如window.resize，Swiper更新
		// hashNavigation: true,
	});
}



// 快捷选单滑动方法
function quickMenuSwiper() {
	return new Swiper('.swiper-container2', {
		pagination: {
			el: '.swiper-pagination',
		},
		initialSlide: object.menuNo,
		centeredSlides: true,
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
	})
}
// 进入搜索页面方法
function goSearch() {
	checkVal()
	var li = ''
	var lis = ''
	$('.searchResults').css('border', '')
	$(".main").children().children().find('div').eq(2).hide()
	$(".main").children().children().find('div').eq(3).fadeIn()
	$(".homePage").fadeOut()
	$('.buildingBar').css('margin-top', '4rem')
	$('.main').fadeIn();
	$('.clearHistoryLabel').show()
	// $(".main .gSearch input").focus()
	$(".input-group input").val('')
	$(".qingKong").css("opacity", "0")
	keyArr = JSON.parse(localStorage.getItem("searchKeyB"))
	keyArr = uniq(keyArr, "name")
	$('.popularSearch').children().remove()
	if (keyArr.length > 0) {
		for (let o = 0; o < keyArr.length; o++) {
			li = li + '<li>' + '<div class="searchResultsImg">' + '<span>' + '</span>' + '</div>' + '<div class="searchResultsInfo"  onclick="historySearch(' + "\'" + keyArr[o].name + "\'" + ', ' + "\'" + keyArr[o].floor + "\'" + ')">' + '<span>' + keyArr[o].name + '</span>' + '<div>' + '</div>' + '<span class="searchResultsInfoFloor">' + keyArr[o].floor + '</span>' + '</div>' + '</li>'
		}
		$('.searchResults').append(li)
	}
	if (popularSearchData.length > 0) {
		var lis = ''
		for (var o = 0; o < popularSearchData.length; o++) {
			if (o < 2) {
				lis = lis + '<li onclick="toThisPoint(' + popularSearchData[o].PI + ',' + "\'" + popularSearchData[o].FI + "\'" + ',' + "\'" + popularSearchData[o].Name + "\'" + ',' + 9 + ',' + "\'" + popularSearchData[o].Tag + "\'" + ')">' + '<div class="searchResultsImg">' + '<span>' + '</span>' + '</div>' + '<div class="searchResultsInfo">' + '<span>' + popularSearchData[o].Name + '</span>' + '<div>' + '</div>' + '<span>' + popularSearchData[o].Tag + '   ' + object.allFoors[popularSearchData[o].FI] + '</span>' + '</div>' + '</li>'
			}
		}
		$('.popularSearch').append(lis)
	}
	if ($('.searchResults').children().length == '') {
		$('.clearHistoryLabel').hide()
	}
}

// 清空搜索缓存方法
function clearHistoryFun() {
	var arrClear = []
	localStorage.setItem("searchKeyB", JSON.stringify(arrClear))
	$('.clearHistoryLabel').hide()
	$('.searchResults').css('border', '')
	$('.searchResults').children().remove()
}

//历史记录搜索方法
function historySearch(name, floor) {
	if (floor == '点击查看更多结果') {
		matchData(name)
		toSearchResultsOnMap(name)
	} else {
		matchData(name)
		$('.searchResults').find('li').eq(0).click()
	}
}

var toClose = true
//科室页楼层展示 伸缩
$(".floorListInfo").on("click", '#buildingTitle', function () {
	if ($(this).siblings().css('display') == 'block') {
		// zhankai
		$(this).siblings().slideUp()
		// toClose = !toClose
		setTimeout(() => {
			$(this).siblings().children().eq(0).css("border-top", "1px solid #e5e5e5")
			// $(this).parent().css("border-radius", '.1rem')
		}, 400);
		$(this).removeClass().addClass("buildingTitleC")
	} else {
		$(this).siblings().slideDown()
		// toClose = !toClose
		$(this).removeClass().addClass("buildingTitle")
		$(this).siblings().children().eq(0).css("border-top", "0")
		// $(this).parent().css("border-radius", '.1rem .1rem 0 0')
	}
})

//进入地图页
function enterMap() {
	$(".homePage").fadeOut()
	$(".main").fadeOut()
	$('.buildingBar').css('margin-top', '4rem')
	if ($(".searchResultsOnMapBox").css('display') == 'block') {
		$(".searchResultsOnMapBox").show()
	}
}

//进入科室页
function enterHomePage(type) {
	setTimeout(() => {
		quickMenuSwiper().progress;
		quickMenuSwiper().pagination.update()
	}, 0);
	isStart = false;
	isEnd = false
	$(".main").hide()
	$(".homePage,.clearHistoryLabel").fadeIn()
	$('.buildingBar').css('margin-top', '0')
	$(".hpInput").val("")
	if ($(".searchResultsOnMapBox").css('display') == 'block') {
		$(".searchResultsOnMapBox").show()
	}
	if (type == 'isStart') {
		isStart = true
		isEnd = false
	} else if (type == 'isEnd') {
		isEnd = true
		isStart = false
	}
}
// 判断input的value判断清空按钮显隐
function checkInput(e) {
	var oVal = $(e).val();
	if (oVal == "") {
		$(".qingKong").css("opacity", "0")
		$('.clearHistoryLabel').hide()
		$('.searchResults').css('border', '')
		$(".main").children().children().find('.enterMapO').hide()
		$('.clearHistoryLabel').hide()
		$(".main").children().children().find('.enterMap').fadeIn()
	} else {
		$(".qingKong").css("opacity", "1")
		$('.searchResults').css('border', '')
		$(".main").children().children().find('.enterMap').hide()
		$('.clearHistoryLabel').hide()
		$(".main").children().children().find('.enterMapO').fadeIn()
	}
}
// input清空按钮  清空输入框方法
function delThisinput(e) {
	$(e).prev().val("")
	$(".qingKong").css("opacity", "0")
	$('.clearHistoryLabel').hide()
	$('.searchResults').children().remove()
	$('.popularSearch').children().remove()
	$(".main").children().children().find('div').eq(2).hide()
	$(".main").children().children().find('div').eq(3).fadeIn()
}
// 路线类型选择
$(".clickDetails .pathChoice div").on("click", function () {
	$(this).find("li").addClass("thisLiIsActive")
	$(this).siblings().find("li").removeClass()
	if ($(this).index() == 0) {
		$(".firstChoice").find("li").eq(1).children().remove()
		$(".firstChoice").find("li").eq(1).html(formatSeconds(realTime))
		$(".firstChoice").find("li").eq(2).children().html('约' + realdistance + '米')
		$(".secondChoice").find("li").eq(1).html(" ")
		$(".secondChoice").find("li").eq(1).append("<span></span>")
		$(".secondChoice").find("li").eq(2).find("span").html("查看扶梯路线")
		$(".lastChoice").find("li").eq(1).html(" ")
		$(".lastChoice").find("li").eq(1).append("<span></span>")
		$(".lastChoice").find("li").eq(2).find("span").html("查看楼梯路线")
		pathGo('liftsFirst')
	} else if ($(this).index() == 1) {
		$(".secondChoice").find("li").eq(1).children().remove()
		$(".secondChoice").find("li").eq(1).html(formatSeconds(realTime))
		$(".secondChoice").find("li").eq(2).children().html('约' + realdistance + '米')
		$(".firstChoice").find("li").eq(1).html(" ")
		$(".firstChoice").find("li").eq(1).append("<span></span>")
		$(".firstChoice").find("li").eq(2).find("span").html("查看直梯路线")
		$(".lastChoice").find("li").eq(1).html(" ")
		$(".lastChoice").find("li").eq(1).append("<span></span>")
		$(".lastChoice").find("li").eq(2).find("span").html("查看楼梯路线")
		pathGo('escalatorsFirst')
	} else if ($(this).index() == 2) {
		$(".lastChoice").find("li").eq(1).children().remove()
		$(".lastChoice").find("li").eq(1).html(formatSeconds(realTime))
		$(".lastChoice").find("li").eq(2).children().html('约' + realdistance + '米')
		$(".firstChoice").find("li").eq(1).html(" ")
		$(".firstChoice").find("li").eq(1).append("<span></span>")
		$(".firstChoice").find("li").eq(2).find("span").html("查看直梯路线")
		$(".secondChoice").find("li").eq(1).html(" ")
		$(".secondChoice").find("li").eq(1).append("<span></span>")
		$(".secondChoice").find("li").eq(2).find("span").html("查看楼梯路线")
		pathGo('stairsFirst')
	}
})
// input val值与后台数据匹配 并渲染
var searchResultsArr = []
// 排序方法截取第一位数
function compareOneDigit(property) {
	return function (a, b) {
		if (a[property]) {
			if (a[property].charAt(0) != '' || b[property].charAt(0) != '') {
				var value1 = a[property].charAt(0)
				var value2 = b[property].charAt(0)
				// console.log(value1)
				return value1 - value2;
			}
		}
	}
}

// 楼层排序方法截取前面数字
function comparefloor(property, str, index) {
	return function (a, b) {
		if (a[property]) {
			if (a[property].split(str)[index] != '' || b[property].split(str)[index] != '') {
				let value1 = a[property].split(str)[index]
				let value2 = b[property].split(str)[index]
				return value1 - value2;
			}
		}
	}
}



// 排序方法全词
function compare(property) {
	return function (a, b) {
		if (a[property]) {
			if (a[property].charAt(0) != '' || b[property].charAt(0) != '') {
				var value1 = a[property]
				var value2 = b[property]
				// console.log(value1)
				return value1 - value2;
			}
		}
	}
}
// 实时搜索匹配方法  并传递搜索结果为数组
function matchData(val) {
	$('.searchResults').children().remove()
	$('.popularSearch').children().remove()
	searchResultsArr = []
	var li = ''
	var nameStr;
	// console.log(allFloorData)
	if (allFloorData.length > 0) {
		for (let i = 0; i < allFloorData.length; i++) {
			searchList = allFloorData[i].Area;
			for (let j = 0; j < searchList.length; j++) {
				nameStr = searchList[j].AN
				if (nameStr.indexOf(val) != -1 && val != "") {
					searchResultsArr.push(searchList[j])
				}
			}
		}
		searchResultsArr = searchResultsArr.sort(compareOneDigit('Tag'))
		for (let o = 0; o < searchResultsArr.length; o++) {
			li = li + '<li onclick="toThisPoint(' + searchResultsArr[o].PI + ',' + "\'" + searchResultsArr[o].FloorID + "\'" + ',' + "\'" + searchResultsArr[o].AN + "\'" + ',' + 9 + ',' + "\'" + searchResultsArr[o].Tag + "\'" + ')">' + '<div class="searchResultsImg">' + '<span>' + '</span>' + '</div>' + '<div class="searchResultsInfo">' + '<span>' + searchResultsArr[o].AN + '</span>' + '<div>' + '</div>' + '<span class="searchResultsInfoFloor">' + searchResultsArr[o].Tag + '   ' + object.allFoors[searchResultsArr[o].FloorID] + '</span>' + '</div>' + '</li>'
		}
		$('.searchResults').append(li)
	} else if (allFloorData.length < 1) {
		$('.searchResults').css('border', '')
	}
}

// 退出导航几种方式
// function exitNavigation(type) {
// 	if (type == 1) {
// 		$(".exitConfirmation").css("opacity", "1")
// 		$(".exitConfirmation").css("right", "0rem")
// 		$(".inNavigationBotBar").css("left", "7.3rem")
// 		setTimeout(() => {
// 			$(".inNavigationBotBar").css("opacity", "0")
// 		}, 500)
// 	} else if (type == 2) {
// 		$(".inNavigationBotBar").css("opacity", "1")
// 		$(".inNavigationBotBar").css("left", "0rem")
// 		$(".exitConfirmation").css("right", "7.3rem")
// 		setTimeout(() => {
// 			$(".exitConfirmation").css("opacity", "0")
// 		}, 500);
// 	} else if (type == 3) {
// 		setTimeout(() => {
// 			object.isTrue = true;
// 			audioAutoPlay("mo_yuyin", "导航结束", "5")
// 		}, 0);
// 		// $('.floorToggle').html("" + object.allFoors[nowFloorId] + "")
// 		$(".inNavigationTopBarBox,.inNavigationBotBarBox").fadeOut()
// 		exitNavigation(2)
// 		clearInterval(realTimeCountdown)
// 		clearInterval(object.timer)
// 		goBack()
// 	} else if (type == 4) {
// 		// $('.floorToggle').html("" + object.allFoors[nowFloorId] + "")
// 		$(".endOfNavigationBox,.inNavigationTopBarBox").fadeOut()
// 		$('.navigationCompletedPopUps').fadeIn()
// 		setTimeout(() => {
// 			$('.navigationCompletedPopUps').fadeOut()
// 		}, 1500);
// 		clearInterval(realTimeCountdown)
// 		clearInterval(object.timer)
// 		goBack()
// 	} else if (type == 5) {
// 		// $('.floorToggle').html("" + object.allFoors[nowFloorId] + "")
// 		$(".endOfNavigationBox,.inNavigationTopBarBox").fadeOut()
// 		$('.navigationCompletedPopUps').fadeIn()
// 		setTimeout(() => {
// 			$('.navigationCompletedPopUps').fadeOut()
// 		}, 1500);
// 		commentPublic = $('.startEndPointRankLabelTextarea textarea').val()
// 		clearInterval(realTimeCountdown)
// 		clearInterval(object.timer)
// 		goBack()
// 		if (!rankPublic) {
// 			Review(projectIdPublic, 4, commentPublic)
// 		} else {
// 			Review(projectIdPublic, rankPublic, commentPublic)
// 		}
// 		console.log(commentPublic)
// 		rankPublic = ''
// 		commentPublic = ''
// 		$(".starability_basic").find("span").css("background-image", "url('./images/icon_xingxing_mr.png')")
// 		$(".startEndPointRankLabel").css('height', '0')
// 		$(".startEndPointRankPickRemark").html("您对本次服务满意吗")
// 		$(".startEndPointRankLabelTextarea textarea").val('')
// 	}
// }
// 进入评分页面
// function enterRank() {
// 	$(".startEndPointInfo").fadeOut()
// 	$(".startEndPointRank").slideDown()
// }
// 回车键调用搜索方法
$(document).keyup(function (event) {
	if ($('.enterMapO').css("display") == 'block') {
		if (event.keyCode == 13) {
			toSearchResultsOnMap()
		}
	}
});
//评分星星按钮
// $(".starability_basic span").on("click", function () {
// 	$(".starability_basic").find("span").css("background-image", "url('./images/icon_xingxing_mr.png')")
// 	var xxIndex = $(this).index()
// 	for (let i = 0; i < xxIndex + 1; i++) {
// 		$(".starability_basic").find("span").eq(i).css("background-image", "url('./images/icon_xingxing_xz.png')")
// 	}
// 	if (xxIndex == 0) {
// 		$(".startEndPointRankPickRemark").html("体验较差")
// 	} else if (xxIndex == 1) {
// 		$(".startEndPointRankPickRemark").html("体验一般")
// 	} else if (xxIndex == 2) {
// 		$(".startEndPointRankPickRemark").html("体验良好")
// 	} else if (xxIndex == 3) {
// 		$(".startEndPointRankPickRemark").html("比较满意")
// 	} else if (xxIndex == 4) {
// 		$(".startEndPointRankPickRemark").html("非常满意")
// 	}
// 	setTimeout(() => {
// 		$(".startEndPointRankLabel").css("height", "2.47rem")
// 	}, 0);
// 	rankPublic = $(this).index()
// 	console.log(rankPublic)
// })
// 评分打标签
// $(".startEndPointRankLabelWords span").on("click", function () {
// 	if ($(".startEndPointRankLabelTextarea textarea").val().indexOf($(this).html()) == -1) {
// 		$(".startEndPointRankLabelTextarea textarea").val($(".startEndPointRankLabelTextarea textarea").val() + " " + $(this).html())
// 	} else {
// 		return
// 	}
// 	commentPublic = $('.startEndPointRankLabelTextarea textarea').val()
// 	console.log(commentPublic)
// })
//科室页  搜索结果   搜索多结果 点击方法
function toThisPoint(pointid, floorid, roomname, type, tag) {
	setTimeout(() => {
		yGetData.updateHotPoint(projectIdPublic, 'SC', 'AddSearchLog', "{'KEY':'" + pointid + "'}")
	}, 100);
	// $(".searchResultsOnMapBox").hide()
	unableClick = {}
	if (type == 9) { //单结果

		object.endP = self.map.endPID = pointid

		if (tag) {
			endPointData = tag + ' ' + object.allFoors[floorid] + ' ' + roomname
		} else {
			endPointData = object.allFoors[floorid] + ' ' + roomname
		}
		$(".homePage,.main,.searchResultsOnMapBox").hide()
		$('.searchResultsOnMapBox_close').removeClass('searchResultsOnMapBox_closeRotate')
		$('.clickDetails .opStartP').val('我的位置')
		$('.clickDetails .opEndP').val(endPointData)
		var a = setInterval(function () {
			if (self.map.pathDownloaded == true) {

				pathGo('liftsFirst')
				clearInterval(a)

			} else {
				self.map.regPathDownloaded(function () {

					pathGo('liftsFirst')
					clearInterval(a)

				})
			}
		}, 500)
	} else if (type == 10) { //多结果
		multipleSelectionEndPoint = pointid
		// object.endP = self.map.endPID = pointid
		self.map.addMarkToPoint(pointid, 'mark', true)
		if (tag) {
			endPointData = tag + ' ' + object.allFoors[floorid] + ' ' + roomname
		} else {
			endPointData = object.allFoors[floorid] + ' ' + roomname
		}
		$(".homePage,.main").hide()
		$('.clickDetails .opStartP').val('我的位置')
		$('.clickDetails .opEndP').val(endPointData)
	} else {

	}
}

// 按钮显示设为起点还是设为终点判断
function isStartBtnOrEndBtn(type) {
	$(".clickDetails .right").children().remove()
	if (type == 1) { //setPointTips专场
		$('.searchResultsOnMapBox,.clickDetails').hide()
		$('.setPointTip').slideDown()
	} else if (type == 2) { //searchResultsOnMapBtn专场
		$('.setPointTip,.clickDetails').hide()
		$('.searchResultsOnMapBox').slideDown()
	} else if (type == 3) { //setPoint专场
		$('.searchResultsOnMapBox,.setPointTip').hide()
		$('.clickDetails').slideDown()
	}
	if (isStart == true) {
		$(".setPointTips").html("起点")
		$(".searchResultsOnMapBtn span").eq(1).html("设起点")
		$(".clickDetails .right").append("<div class = 'querenxuandian' onclick='setStart()'>设为起点</div>")
	} else if (isEnd == true) {
		$(".setPointTips").html("终点")
		$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		$(".clickDetails .right").append("<span class = 'setPointBtn' onclick='setStartOrEnd()'></span>")
	} else {
		if ($('.opStartP').val() == '' && $('.opEndP').val() != '') {
			$(".setPointTips").html("起点")
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
			$(".clickDetails .right").append("<div class = 'querenxuandian' onclick='setStart()'>设为起点</div>")
		} else if ($('.opEndP').val() == '' && $('.opStartP').val() != '') {
			$(".setPointTips").html("终点")
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
			$(".clickDetails .right").append("<span class = 'setPointBtn' onclick='setStartOrEnd()'></span>")
		} else if ($('.opEndP').val() == '' && $('.opStartP').val() == '') {
			$(".setPointTips").html("终点")
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
			$(".clickDetails .right").append("<span class = 'setPointBtn' onclick='setStartOrEnd()'></span>")
		}
	}

}

//   接下来是设置起点还是终点
function setPointType(type, pointid, floorid, roomname, tag) {
	$('.setPointTip').hide()
	if (type == 'start') {
		object.startP = self.map.startPID = pointid
		if (tag) {
			$('.opStartP').val(tag + ' ' + object.allFoors[floorid] + ' ' + (roomname));

		} else {
			$('.opStartP').val(object.allFoors[floorid] + ' ' + (roomname));
		}

		if (object.startP != '' && object.endP != '') {
			$(".selectionBox").slideDown()
			$('.selection').hide()
			$('.selectionLoading').show()
			// selectionBoxBottm()
			setTimeout(() => {
				$(".loadings").hide()
				setTimeout(() => {
					$('.selection').fadeIn()
					$('.selectionLoading').hide()
				}, 500);
				pathGo('liftsFirst')
			}, 500);
		}
	} else if (type == 'end') {
		object.endP = self.map.endPID = pointid
		if (tag) {
			$('.opEndP').val(tag + ' ' + object.allFoors[floorid] + ' ' + (roomname));
		} else {
			$('.opEndP').val(object.allFoors[floorid] + ' ' + (roomname));
		}

		if (object.startP != '' && object.endP != '') {
			$(".selectionBox").slideDown()
			$('.selection').hide()
			$('.selectionLoading').show()
			// selectionBoxBottm()
			setTimeout(() => {
				$(".loadings").hide()
				setTimeout(() => {
					$('.selection').fadeIn()
					$('.selectionLoading').hide()
				}, 500);
				pathGo('liftsFirst')
			}, 500);
		}
	}
}
//  搜索结果置于地图表面 搜索结果li点击效果
$(".searchResultsOnMapContainer").on("click", 'li', function () {
	$(this).addClass("searchResultsLiIsClick")
	$(this).siblings().removeClass()
})
// 搜索结果置于地图表面 顶部点击收缩
// $(".searchResultsOnMap div").eq(0).on("click", function () {
// 	if ($(".searchResultsOnMapTelescopic").css('display') == 'block') {
// 		$(".searchResultsOnMapTelescopic,.clickDetails").slideUp()
// 		$(this).children().eq(0).html("查看其余" + $(".searchResultsOnMapContainer li").length + "个结果")
// 		$(this).removeClass().addClass("searchResultsOnMapTopBarIsClick")
// 		$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '1rem')
// 		// $(".floorToggle").css('bottom', '0.95rem')
// 	} else if ($(".searchResultsOnMapTelescopic").css('display') == 'none') {
// 		$(".searchResultsOnMapTelescopic").slideDown()
// 		$(this).removeClass().addClass("searchResultsOnMapTopBar")
// 		$(this).children().eq(0).html("收起搜索结果")
// 		dynamicBottom()
// 	}
// })
//数组内对象去重    
function uniq(arr, name) {
	var hash = {};
	return arr.reduce(function (item, next) {
		hash[next[name]] ? '' : hash[next[name]] = true && item.push(next);
		return item;
	}, []);
}
//从搜索页 搜索按钮进入搜索结果置于地图表面
function toSearchResultsOnMap(name) {
	var li = ''
	noMarkIsSetEnd = false
	$(".searchResultsOnMapContainer,.searchResults").children().remove()
	if (searchResultsArr.length > 0) {
		console.log('searchResultsArr :', searchResultsArr);
		var sArr = {}
		keyArr = JSON.parse(localStorage.getItem("searchKeyB"))
		if (name) {
			sArr.name = name
		} else if ($('.form-control').val() != '') {
			sArr.name = $('.form-control').val()
		}
		sArr.floor = '点击查看更多结果'
		if (keyArr == '' || keyArr == null) {
			var cArr = []
			cArr.push(sArr)
			localStorage.setItem("searchKeyB", JSON.stringify(cArr))
		}
		keyArr = JSON.parse(localStorage.getItem("searchKeyB"))
		keyArr.push(sArr)
		localStorage.setItem("searchKeyB", JSON.stringify(keyArr))
		keyArr = JSON.parse(localStorage.getItem("searchKeyB"))
		// console.log(keyArr)
		var keyArr = []
		noMarkIsSetEnd = true
		for (let i = 0; i < searchResultsArr.length; i++) {
			li = li + '<li onclick="toThisPoint(' + searchResultsArr[i].PI + ',' + "\'" + searchResultsArr[i].FloorID + "\'" + ',' + "\'" + searchResultsArr[i].AN + "\'" + ',' + 10 + ',' + "\'" + searchResultsArr[i].Tag + "\'" + ')">' + '<div>' + '<span>' + '</span>' + '</div>' + '<div>' + '<div>' + '<span>' + searchResultsArr[i].AN + '</span>' + '<span>' + searchResultsArr[i].Tag + " " + object.allFoors[searchResultsArr[i].FloorID] + '</span>' + '</div>' + '<div class="searchResultsEnterDetailsBtn">' + '<span>' + '</span>' + '</div>' + '</div>' + '</li>'
		}
		if (object.startP == '' && object.endP != '') {
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
		} else if (object.endP == '' && object.startP != '') {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		} else if (object.startP == '' && object.endP == '') {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		}
		if (isStart == true) {
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
			$(".floorToggleMinUl").hide()
			$('.pathInfo').hide()
		} else if (isEnd == true) {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
			$(".floorToggleMinUl").hide()
			$('.pathInfo').hide()
		}
		$(".searchResultsOnMapContainer").append(li)
		$(".searchResultsOnMapContainer li").eq(0).click()
		$(".main").hide()
		if (searchResultsArr.length == 1) {

			// $('.searchResultsEnterDetailsBtn').click()
			$('.searchResultsOnMapBox').slideDown(() => {
				$('.searchResultsOnMapBox_close').addClass('searchResultsOnMapBox_closeRotate')
			})
			// $('.clickDetails').show()
			// setPointBottom()
		} else {

			$(".searchResultsOnMapTelescopic").slideDown()
			$(".searchResultsOnMapBox").fadeIn(() => {
				$('.searchResultsOnMapBox_close').addClass('searchResultsOnMapBox_closeRotate')
			})
			searchResultsOnMapBoxH = ($('.searchResultsOnMapBox').height()) / (document.documentElement.clientWidth / 7.5)
			setTimeout(() => {
				// dynamicBottom()
			}, 500);
		}
		searchResultsArr = ''
	} else if (afterFastSearchData.length > 0) {
		noMarkIsSetEnd = true
		var lFloor = [],
			BFloor = [];

		afterFastSearchData.forEach(element => {
			element.floor = object.allFoors[element.FloorID]
		})
		afterFastSearchData.forEach(element => {
			if (element.floor.indexOf('B') != -1) {
				BFloor.push(element)
			} else if (element.floor.indexOf('L') != -1) {
				lFloor.push(element)
			}
		})

		BFloor.sort(comparefloor('floor', 'B', 1))
		lFloor.sort(comparefloor('floor', 'L', 1))

		afterFastSearchData = BFloor.concat(lFloor);

		for (let i = 0; i < afterFastSearchData.length; i++) {
			li = li + '<li onclick="toThisPoint(' + afterFastSearchData[i].PI + ',' + "\'" + afterFastSearchData[i].FloorID + "\'" + ',' + "\'" + afterFastSearchData[i].BN + "\'" + ',' + 10 + ',' + "\'" + afterFastSearchData[i].T + "\'" + ')">' + '<div>' + '<span>' + '</span>' + '</div>' + '<div>' + '<div>' + '<span>' + afterFastSearchData[i].BN + '</span>' + '<span>' + afterFastSearchData[i].T + '   ' + object.allFoors[afterFastSearchData[i].FloorID] + '</span>' + '</div>' + '<div class="searchResultsEnterDetailsBtn">' + '<span>' + '</span>' + '</div>' + '</div>' + '</li>'
		}
		if (object.startP == '' && object.endP != '') {
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
		} else if (object.endP == '' && object.startP != '') {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		} else if (object.startP == '' && object.endP == '') {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		}
		if (isStart == true) {
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
			$(".floorToggleMinUl").hide()
			$('.pathInfo').hide()
		} else if (isEnd == true) {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
			$(".floorToggleMinUl").hide()
			$('.pathInfo').hide()
		}
		$(".searchResultsOnMapContainer").append(li)
		$(".searchResultsOnMapContainer li").eq(0).click()
		if (afterFastSearchData.length == 1) {
			// $('.searchResultsEnterDetailsBtn').click()
			$('.searchResultsOnMapBox').slideDown(() => {
				$('.searchResultsOnMapBox_close').addClass('searchResultsOnMapBox_closeRotate')
			})
			// setPointBottom()
		} else {
			$(".main").hide()
			$(".searchResultsOnMapTelescopic").slideDown()
			$(".searchResultsOnMapBox").fadeIn(() => {
				$('.searchResultsOnMapBox_close').addClass('searchResultsOnMapBox_closeRotate')
			})
			searchResultsOnMapBoxH = ($('.searchResultsOnMapBox').height()) / (document.documentElement.clientWidth / 7.5)
			setTimeout(() => {
				// dynamicBottom()
			}, 500);

		}
		afterFastSearchData = ''
	} else {
		$('.searchResults').append("<span>未查找到结果</span>")
	}

	if ($('.searchResultsOnMapContainer').children != '') {
		$('.searchResultsOnMapContainer').animate({
			scrollTop: 0
		}, 'normal');
	}
}

// 多结果搜索呈现于地图点击箭头跳转单项详情
// $(".searchResultsOnMapContainer").on("click", '.searchResultsEnterDetailsBtn', function () {
// 	// $(".pointName").html($(this).prev().children().eq(0).html())
// 	// $('.pointFloor').html($(this).prev().children().eq(1).html())
// 	// $(".searchResultsOnMapBox").slideUp()
// 	// $(".clickDetails").fadeIn()
// 	// isStartBtnOrEndBtn(3)
// 	// setPointBottom()
// 	setStartOrEnd()
// })

// 根据情况选择设置起点方法还是设置终点方法
function setStartOrEnd() {
	object.endP = self.map.endPID = multipleSelectionEndPoint
	var a = setInterval(function () {
		if (self.map.pathDownloaded == true) {
			pathGo('liftsFirst')
			clearInterval(a)
		} else {
			self.map.regPathDownloaded(function () {
				pathGo('liftsFirst')
				clearInterval(a)
			})
		}
	}, 500)
}
// 没有点击事件的标签设起点终点方法
// function unableClickFun(type) {
// 	if (type == 1) {
// 		$('.operation').show()
// 		object.startP = self.map.startPID = unableClick.pointID
// 		if (unableClick.tag) {
// 			$('#startPoint').val(unableClick.tag + ' ' + object.allFoors[unableClick.floorID] + ' ' + (unableClick.name));
// 		} else {
// 			$('#startPoint').val(object.allFoors[unableClick.floorID] + ' ' + (unableClick.name));
// 		}

// 		if (object.startP != '' && object.endP != '') {
// 			$('.selectionBox').show()
// 			$(".setPointTip").hide()
// 			selectionBoxBottm()
// 			setTimeout(() => {
// 				$(".loadings").hide()
// 				setTimeout(() => {
// 					$('.selection').fadeIn()
// 					$('.selectionLoading').hide()
// 				}, 500);
// 				pathGo('liftsFirst')
// 			}, 500);
// 		} else {
// 			isStartBtnOrEndBtn(1)
// 			setPointTipBottom()
// 			$('.compass').css('top', '2.81rem')
// 		}
// 	} else if (type == 2) {
// 		$('.operation').show()
// 		object.endP = self.map.endPID = unableClick.pointID
// 		if (unableClick.tag) {
// 			$('#endPoint').val(unableClick.tag + ' ' + object.allFoors[unableClick.floorID] + ' ' + (unableClick.name));
// 		} else {
// 			$('#endPoint').val(object.allFoors[unableClick.floorID] + ' ' + (unableClick.name));
// 		}

// 		if (object.startP != '' && object.endP != '') {
// 			$('.selectionBox').show()
// 			$(".setPointTip").hide()
// 			selectionBoxBottm()
// 			setTimeout(() => {
// 				$(".loadings").hide()
// 				setTimeout(() => {
// 					$('.selection').fadeIn()
// 					$('.selectionLoading').hide()
// 				}, 500);
// 				pathGo('liftsFirst')
// 			}, 500);
// 		} else {
// 			isStartBtnOrEndBtn(1)
// 			setPointTipBottom()
// 			$('.compass').css('top', '2.81rem')
// 		}
// 	}
// }
// 评分重置
// function RankPageReset() {
// 	$(".starability_basic").find("span").css("background-image", "url('./images/icon_xingxing_mr.png')")
// 	$(".startEndPointRankLabel").css('height', '0')
// 	$(".startEndPointRankPickRemark").html("您对本次服务满意吗")
// 	$(".startEndPointRankLabelTextarea textarea").val('')
// }
// 秒钟换算
function formatSeconds(value) {
	var theTime = parseInt(value); // 秒
	var theTime1 = 0; // 分
	var theTime2 = 0; // 小时
	if (theTime > 60) {
		theTime1 = parseInt(theTime / 60);
		theTime = parseInt(theTime % 60);
		if (theTime1 > 60) {
			theTime2 = parseInt(theTime1 / 60);
			theTime1 = parseInt(theTime1 % 60);
		}
	}
	if (parseInt(theTime) > 0) {
		var result = "" + parseInt(theTime) + "秒";
		if (theTime1 > 0) {
			result = "" + parseInt(theTime1) + "分" + result;
		}
		if (theTime2 > 0) {
			result = "" + parseInt(theTime2) + "小时" + result;
		}
	} else {
		var result = ''
		if (theTime1 > 0) {
			result = "" + parseInt(theTime1) + "分钟" + result;
		}
		if (theTime2 > 0) {
			result = "" + parseInt(theTime2) + "小时" + result;
		}
	}
	return result
}
// 强制关loading
$(".loadings div").on('click', function () {
	$(".loadings").fadeOut()
})

// 地图位置 大小初始化
function mapPositonReset() {
	if (object.isFind) {
		self.map.zoomLevel(pLevel)
	} else {
		mapResetPublic()
	}
}

// 滑动收起键盘
// $(".searchResultsBox").on("touchstart", function (e) {
// 	$('.form-control').blur()
// });

// 选点模块出现后   楼层模块和缩放模块的bottom位置
// function setPointBottom() {
// 	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '1.2rem');
// 	// $(".floorToggle").css('bottom', '1.15rem')
// }

// function setPointTipBottom() {
// 	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '1.7rem');
// 	// $(".floorToggle").css('bottom', '1.65rem')
// }

// function selectionBoxBottm() {
// 	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '3rem');
// 	// $(".floorToggle").css('bottom', '2.95rem')
// }

// function normalBottom() {
// 	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '1.2rem');
// 	// $(".floorToggle").css('bottom', '1.15rem')
// }

// function dynamicBottom() {
// 	console.log(searchResultsOnMapBoxH)
// if ($('.searchResultsOnMapContainer li').length == 1) {
// 	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '' + (searchResultsOnMapBoxH + 1.9) + 'rem')
// 	$(".floorToggle").css('bottom', '' + (searchResultsOnMapBoxH + 1.75) + 'rem')
// } else if ($('.searchResultsOnMapContainer li').length == 2) {
// 	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '' + (searchResultsOnMapBoxH + 2.5) + 'rem')
// 	$(".floorToggle").css('bottom', '' + (searchResultsOnMapBoxH + 2.35) + 'rem')
// } else if ($('.searchResultsOnMapContainer li').length > 2) {
// 	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '' + (searchResultsOnMapBoxH + 3) + 'rem')
// 	$(".floorToggle").css('bottom', '' + (searchResultsOnMapBoxH + 2.85) + 'rem')
// }
// $('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '' + (searchResultsOnMapBoxH + .2) + 'rem')
// $(".floorToggle").css('bottom', '' + (searchResultsOnMapBoxH + .15) + 'rem')
// }

// function shareFun() {
// 	shareMessage()
// 	shareTimeline()
// }

//  测试阶段，本导航信息仅做参考，请以医院现场实际位置为准页关闭
// function floorListHintClose() {
// $('.floorListHintBox').fadeOut()
// }

// 二维码页关闭
function closeClickDetails() {
	$(".clickDetails").fadeOut()
	$('.clickDetails .clickDetailsClose').hide();
	$('.clickDetails .clickDetailsClose span').removeClass('clickDetailsCloseFadeOut')
	$('.floorToggleMinUl').hide()
	$('.pathInfo').hide()
	$('.changeFBox').show()
	goBack()
}

// 快速导航信息栏关闭
$('.searchResultsOnMapTopBar .searchResultsOnMapBox_close').on('click', () => {
	$(".searchResultsOnMapBox").fadeOut()
	$('.searchResultsOnMapBox_close').removeClass('searchResultsOnMapBox_closeRotate')
	if ($('.floorToggleMinUl').css("display") == 'none') {
		$('.changeFBox').show()
	}

})




// 时间刷新 1s
function fnDateRefresh() {
	fnDate()
	setInterval(() => {
		fnDate()
	}, 1000);
}

//js 获取当前时间
function fnDate() {
	var date = new Date();
	var year = date.getFullYear(); //当前年份
	var month = date.getMonth(); //当前月份
	var data = date.getDate(); //天
	var hours = date.getHours(); //小时
	var minute = date.getMinutes(); //分
	// var second = date.getSeconds(); //秒
	nowDate = year + "-" + fnW((month + 1)) + "-" + fnW(data);
	nowTime = fnW(hours) + ":" + fnW(minute);
	// console.log(nowTime)
	$('.dateTime_Time').html(nowTime)
	$('.dateTime_Date').html(nowDate)
	$(".dateTime").fadeIn()
	$('.dateTimeload').hide()
}

//补位 当某个字段不是两位数时补0
function fnW(str) {
	var num;
	str >= 10 ? num = str : num = "0" + str;
	return num;
}


// .5h 拉去一次天气数据
function getWeatherDataRefresh() {
	getWeatherData()
	setInterval(() => {
		getWeatherData()
	}, 1800000);
}
//拉天气数据
function getWeatherData() {
	var a = '高平'
	$.ajax({
		url: 'https://service.chaunve.com/CkioskWeatherService.asmx/GetWeatherJson?Project=' + projectIdPublic + '&CityName=' + a + '',
		type: 'get',
		success: function (datas) {
			nowWeather = datas.CurrentTemperature
			if (nowWeather) {
				$('.dateTime_Weather').html(nowWeather)
			} else {
				$('.dateTime_Weather').html('--')
			}
		}
	})
}

// 通过pointid寻找所在楼层
function findFlooridByPointid(pointid) {
	// console.log(allFloorData)
	for (let i = 0; i < allFloorData.length; i++) {
		var a = allFloorData[i].Area
		for (let j = 0; j < a.length; j++) {
			if (pointid == a[j].PI) {
				return allFloorData[i].FloorID
			}
		}
	}
}
//检查输入框的值
function checkVal() {
	var a = setInterval(function () {
		if ($('.main').css('display') != ('block')) {
			$('#keyboard').fadeOut()
			$('#simle_input_method').hide()
			clearInterval(a)
		}
	}, 10)
}


$("#name_0").on('click', () => {
	$('#keyboard').fadeIn()
})

// 生成url     二维码     插入二维码
function generateUrl(obj) {
	var a = 'https://wx.chaunve.com/H5/map/GPRMYY_Mobile/'
	var qrImgUrl = ''
	var aUrl = a + '?' + 'qrCodePathFind' + '=' + JSON.stringify(obj);
	$.ajax({
		url: 'https://service.chaunve.com/ImageService.asmx/GetUrlQRImage?url=' + aUrl + '',
		type: 'get',
		dataType: 'text',
		success: function (datas) {
			var i = datas.indexOf('qrimageurl')
			var j = datas.indexOf('jpg')
			qrImgUrl = datas.substring(i + 12, j + 4)
		}
	})
	var run = function () {
		if (qrImgUrl.length > 1) {
			$(".clickDetails .clickDetailsQR").children().eq(0).css({
				'background-image': 'url(' + (qrImgUrl.toString()) + ')',
				'background-size': '1rem',
				'background-position': '25%'
			})
			clearInterval(runTime)
		}
	}
	var runTime = setInterval(function () {
		run()
	})
}

function toggleKeShiOrMap() {
	if ($('.homePage').css('display') == 'none') {
		enterHomePage()
	} else {
		enterMap()
	}
}


// 模拟导航方法
function simulateNavigate() {
	if (object.startP == object.endP) {
		$(".searchPathFailMsg").html("此处为您当前位置,请重新设置")
		$(".searchPathFailBox").fadeIn()
		return
	} else {
		setTimeout(() => {
			$(".floorToggleMinUl li").eq(-1).removeClass().addClass('floorToggleUl_List-active');
			$(".floorToggleMinUl li").eq(-1).siblings().removeClass().addClass('floorToggleUl_List')
			$(".floorToggleMinUl li").eq(-1).find("i").removeClass().addClass('floorToggleMinUl_iR');
			$(".floorToggleMinUl li").eq(-1).siblings().find("i").removeClass().addClass('floorToggleMinUl_i')
		}, 0);
		self.map.zoomLevel(15);
		$(".floorToggleMinUl li button").attr("disabled", "true")
		self.map.simulate()
		self.map.regNavigationWalk(function (walkDetail) {
			if (walkDetail.z == 0) {
				if ((walkDetail.turn == 'Lifts' && walkDetail.dis == 0) || (walkDetail.turn == 'Escalator' && walkDetail.dis == 0) || (walkDetail.turn == 'stair' && walkDetail.dis == 0)) {

					setTimeout(() => {
						$(".floorToggleUl_List-active").prev().removeClass().addClass("floorToggleUl_List-active").siblings().removeClass().addClass("floorToggleUl_List")
						$(".floorToggleUl_List-active").find("i").removeClass().addClass("floorToggleMinUl_iR").parent().siblings().find("i").removeClass().addClass("floorToggleMinUl_i")
						$(".floorToggleUl_List-active").attr('data', 'isMark')
						$(".floorToggleUl_List-active").siblings().attr('data', ' ')
					}, 500);
				}
				if (walkDetail.dis == 0 && walkDetail.turn == 'end') {
					setTimeout(() => {
						goBack();
						$(".floorToggleMinUl").hide();
						$('.changeFBox').show()
						$('.mogo').css("background-image", "url('./images/mogo.png')");
						$('.mogo').text('点击进行模拟导航');
						$('.navigationCompletedPopUps').fadeIn(100, () => {
							setTimeout(() => {
								$('.navigationCompletedPopUps').fadeOut(1000);
							}, 500);
						})
					}, 1000);
				}
			}
		});
	}
}


//鼠标移动，重置延时任务
function resetTask() {
	clearTimeout(resetTime);
	resetTime = setTimeout("delayTask()", 60000);
}

//延时任务具体的操作
function delayTask() {
	if (!pathFlag) {
		goBack();
		enterHomePage()
		clearTimeout(resetTime);
		if ($('#simle_input_method').css('dispaly') != 'none') {
			$('#simle_input_method').hide();
			searchPathFailClose()
		}
	}

}

// 返回按钮点击事件
$('.searchBack').on('click', () => {
	closeClickDetails();
	goBack();
	enterHomePage();
})


$('.inputSearchBack').on('click', () => {

	enterMap()
})


// PC触摸屏拖拽滚动
function listScroolPc() {
	var mySwiper = new Swiper('.floorListInfo', {
		direction: 'vertical',
	})
}

$(function () {

	// 当科室导航页上下偏移太多强制还原
	$('.floorListInfo').on('mousemove', function () {
		var scroolNum = parseFloat($('.buildingBar').css('transform').substring(8).split(',')[5]);
		if (scroolNum < -500) {
			$(".buildingBar").css('transform', 'translate3d(0px, -450px, 0px)')
		}
		if (scroolNum > 100) {
			$(".buildingBar").css('transform', 'translate3d(0px, 0px, 0px)')
		}
	})
})


// 点击遮罩提示信息
$('.mask').on('click', function () {
	$('.searchPathNoClickInfo').stop().fadeIn(100, () => {
		setTimeout(() => {
			$('.searchPathNoClickInfo').stop().fadeOut(1000);
		}, 500);
	})
})